/**
 * @file RssReader.hpp
 * @author your name (you@domain.com)
 * @brief
 * @version 0.1
 * @date 2022-04-05
 *
 * @copyright Copyright (c) 2022
 *
 */

#pragma once

#include "tinyxml2.h"
#include <memory>
#include <string>
#include <vector>

using std::shared_ptr;
using std::string;
using std::vector;
using namespace tinyxml2;

struct RssItem {
    string _title;
    string _link;
    string _pubDate;
    string _content;
};

struct RssData {
    string _version;
    string _title;
    string _link;
    string _description;
    string _language;
    vector<shared_ptr<RssItem>> _items;
};

class RssReader
{
  public:
    RssReader(vector<string> &files);
    ~RssReader();

    void loadFeedFiles();

    void loadFeedFile(const string &filename);
    void initWithRssString(const string &rss);
    void makePages(vector<string> &pages);

  private:
    void parseRss(XMLDocument &doc);
    // string debug();
    // void dump(const string & filename);
  private:
    vector<shared_ptr<RssItem>> _items;
    vector<string> &_files;
};
